With the rise of smart hardware, more and more smart devices are entering people's lives. Accordingly, how to enable a WiFi-type smart device (which is a smart device with a built-in WiFi module, and may access a network by using the WiFi module) to access a network has become a problem.
As WiFi-type smart devices, such as a smart air conditioner, a smart humidifier, and a smart weighing machine, do not have include screen similar to PCs, mobile phones, tablet computers, and so on, a user cannot connect such WiFi-type smart devices to a network by manually finding a wireless router and entering a password. In other words, lots of WiFi-type smart devices may detect a nearby wireless router, but cannot let users know what networks the devices detect or “see”. The users cannot connect the WiFi-type smart devices to the network by using direct manual interaction (for example, entering a service set identifier (SSID) and a password of the wireless router by using a keyboard or touch screen).
The following several implementation methods are mainly employed in the industry at present to solve the foregoing problem.
First method: a mobile phone sends a data packet to a router by using the User Datagram Protocol (UDP), and the router forwards the data packet. The data packet may carry only a small amount of information, that is, one packet may only carry 1-byte information at most. Therefore, a group of data packets need to be sent, and WiFi networking information is transmitted based on a regular change of the packet length. The WiFi-type smart device parses a group of data packets and acquires WiFi networking information from the data packets, to access the network.
For this method, many data packets need to be sent, and the sending process takes a long sending time, leading to an excessively long time for the WiFi-type smart device to acquire the WiFi networking information. In addition, to prevent packet loss, high development requirements or skills are imposed on the development of a fault-tolerant algorithm, increasing the technological complexity.
Second method: a mobile phone sends a multicast data packet to a router by using the UDP, and the router forwards the multicast data packet. The WiFi-type smart device parses the multicast data packet and acquires WiFi networking information from the multicast data packet, to access the network. However, this method has a prominent multicast compatibility problem. Some routers on which a specific option (e.g., IGMP Snooping) is enabled will not forward the multicast data packet. Thus, the WiFi-type smart device cannot access the network in a short time.